@extends('layouts.admin')
@section('title')
    <title>关注信息</title>
@endsection
@section('content')
    @include('layouts.left')
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
           <h3> 关注信息</h3>
        </section>
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <h3 class="box-title"><a type="button" class="btn btn-block btn-success" href="{{ url('sfollow') }}/create">添加信息</a></h3>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <table id="example2" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>id</th>
                                    <th>shopid</th>
                                    <th>uid</th>
                                    <th>店铺名称</th>
                                    <th>用户名称</th>
                                    <th>关注时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody class="mparent">
                                @foreach($datas as $data)
                                        <tr>
                                            <td>{{$data -> id}}</td>
                                            <td>{{$data -> shopid }}</td>
                                            <td>{{$data -> uid}}</td>
                                            <td>{{$data -> shopname }}</td>
                                            <td>{{$data -> username}}</td>
                                            <td><?php echo date('Y-m-d',$data -> followdate); ?></td>
                                            <td><a href="{{url('sfollow')}}/{{ $data -> id }}/edit"><i class="fa fa-pencil"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="sfollow_delete(this,{{ $data -> id }})"><i class="fa fa-trash-o"></i></a></td>
                                        </tr>
                                @endforeach
                                </tbody>

                            </table>
                        </div>
                        <!-- /.box-body -->
                    </div>
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <!-- 在这里 写js函数-->
    <script type="text/javascript">
        function sfollow_delete(e,id){
            $.ajaxSetup({
                headers:{
                    'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')
                }
            });
            var tr = $(e).closest("tr");
            if(confirm("确定要删除此条数据吗？"))
                $.ajax({
                    url:"{{ url('sfollow') }}/"+id,
                    type:"DELETE",
                    data:{id:id},
                    success:function(data){
                        if(data.status == 'success'){
                            alert(data.msg);
                            tr.remove();

                        }else{
                            alert(data.msg);
                        }
                    },
                    dataType:'json'
                });
        }
    </script>
@endsection


